//********************************************************************************************************************//
//ORGANIZATION:
//AUTHOR: bpeng(bogers.peng@gmail.com)
//SUMMARY:
//********************************************************************************************************************//
#ifndef NATIVE_SYSTEM_BASE_ATOM_H
#define NATIVE_SYSTEM_BASE_ATOM_H

#ifndef NATIVE_SYSTEM_BASE_PRECOMPILED_H
#include "System/Base/Precompiled.h"
#endif

namespace Native { namespace System
{
    //****************************************************************************************************************//
    //Redefine
    //
    //****************************************************************************************************************//
    typedef uint8_t byte_t;
    typedef byte_t* pointer_t;
    typedef string mstring;
    typedef const mstring MSTRING;
    typedef const wstring WSTRING;
    typedef const pointer_t POINTER;
    typedef const byte_t BYTE;
    typedef const wchar_t* CWSTRING;

    const static wstring EMPTY_STRING = L"";
    const static wstring TRUE_STRING = L"true";
    const static wstring FALSE_STRING = L"false";
    const static wstring SPACE_STRING = L" ";

    struct NATIVE_LIBRARY_EXPORT UString
    {
        static const size_t BUFFER_SIZE = 255;

        inline static wstring ToWideString(MSTRING& input, bool appended = false);
        inline static mstring ToMultipleString(WSTRING& input, bool appended = false);
        inline static vector<wstring> Split(WSTRING& input, wchar_t separator);
        inline static wstring ToLower(WSTRING& input);
        inline static wstring ToUpper(WSTRING& input);
    };

    //****************************************************************************************************************//
    //Constant and enum type according to c++ type
    //****************************************************************************************************************//
#ifdef NATIVE_INSTRUCTION_X86
    const static size_t MAX_THROUGHPUT_BITES = 64;
#endif
#ifdef NATIVE_INSTRUCTION_IA64
    const static size_t MAX_THROUGHPUT_BITES = 128;
#endif
#ifdef NATIVE_INSTRUCTION_X64
    const static size_t MAX_THROUGHPUT_BITES = 128;
#endif

    const static size_t BYTE8_SIZE = sizeof(uint8_t);
    const static size_t BYTE16_SIZE = sizeof(uint16_t);
    const static size_t BYTE32_SIZE = sizeof(uint32_t);
    const static size_t BYTE64_SIZE = sizeof(uint64_t);
    const static size_t MAX_BINARY_LENGTH = 64;
    const static size_t MAX_OCTONARY_LENGTH = 21;
    const static size_t MAX_HEXADECIMAL_LENGTH = 18;
    const static size_t MAX_DECIMAL_LENGTH = 20;

    enum NATIVE_LIBRARY_EXPORT EBase
    {
        BASE_BINARY = 2,
        BASE_OCTONARY = 8,
        BASE_DECIMAL = 10,
        BASE_HEXADECIMAL = 16
    };

    //****************************************************************************************************************//
    //UNumeric
    //
    //****************************************************************************************************************//
    struct NATIVE_LIBRARY_EXPORT UNumeric
    {
        inline static wstring ToString(uint8_t numeric, EBase base=BASE_DECIMAL);
        inline static wstring ToString(int8_t numeric, EBase base=BASE_DECIMAL);
        inline static wstring ToString(uint16_t numeric, EBase base=BASE_DECIMAL);
        inline static wstring ToString(int16_t numeric, EBase base=BASE_DECIMAL);
        inline static wstring ToString(uint32_t numeric, EBase base=BASE_DECIMAL);
        inline static wstring ToString(int32_t numeric, EBase base=BASE_DECIMAL);
        inline static wstring ToString(uint64_t numeric, EBase base=BASE_DECIMAL);
        inline static wstring ToString(int64_t numeric, EBase base=BASE_DECIMAL);
    };

    //****************************************************************************************************************//
    //UBool
    //
    //****************************************************************************************************************//
    struct NATIVE_LIBRARY_EXPORT UBool
    {
        inline static wstring ToString(bool value);
    };

#define NATIVE_REDEFINE(ACCESS, SOURCE, TYPE, CONST_TYPE) \
ACCESS:\
    typedef SOURCE TYPE;\
    typedef const TYPE CONST_TYPE;
}}

#endif